#pragma once

#include "cqsdk/cqsdk.h"
#include "httplib.h"
#include <ctime>
#include <curl/curl.h>
#include <nlohmann/json.hpp>
#include <queue>
#include <thread>
#include <filesystem>

namespace privilege
{
	using namespace std;
	using json = nlohmann::json;
	namespace database
	{
		struct richMember
		{
			int64_t user_id;
			string nickname;
		};

		struct richGroup
		{
			int64_t group_id;
			string group_name;
			int32_t member_count;
			vector<richMember> group_member_vector;
		};
		
		void readAuthData(json& authDataJson);
        void saveAuthData(json authDataJson);
        void syncAuthData(json& authDataJson);
        void syncMemberData(json& authDataJson);

        bool checkPermission(json& authDataJson, int64_t group_id, int64_t user_id, int permission_level);
        int getPermission(json& authDataJson, int64_t group_id, int64_t user_id);
        void setPermission(json& authDataJson, int64_t group_id, int64_t user_id, int64_t admin_id, int auth_level);
	}
	namespace core
	{
		string quotation_marks_remover(string rawString);
	}
}